'use strict';

const _ = require('lodash');
const path = require('path');
const {exec} = require('child_process');
const {Controller} = require('ee-core');
const {
    app: electronApp, dialog, shell, BrowserView, session, Notification, sessionpowerMonitor, screen, nativeTheme
} = require('electron');
const Ps = require('ee-core/ps');
const Log = require('ee-core/log');
const dayjs = require('dayjs');
const axios = require('axios')
const fs = require('fs');

/**
 * Requests控制器
 * @class
 */
class RequestsController extends Controller {

    constructor(ctx) {
        super(ctx);
    }

    /**
     * 打开默认浏览器
     */

    async openBrowser(arg) {
        const {url = "https://www.baidu.com"} = arg
        shell.openExternal(url)
    }

    /**
     * 打开文件路径
     * */
    async openPath(arg) {
        const {dir} = arg
        if (dir) {
            shell.openExternal(dir)
        }

    }

    /**
     * 最小化窗口
     * */
    async min() {
        await this.app.electron.mainWindow.minimize();
    }

    /**
     * 最大化窗口
     * */
    async max(){
        if ( this.app.electron.mainWindow.isMaximized()) {
            this.app.electron.mainWindow.restore();
        } else {
            this.app.electron.mainWindow.maximize();
        }

    }

    /**
     * 关闭窗口
     * */
    async close(){
        await  this.app.electron.mainWindow.close()
    }



}

RequestsController.toString = () => '[class RequestsController]';
module.exports = RequestsController;
